money = 5000  # 账户金额
a = ['水果', '零食', '衣服', '饮料', '家具', '电子产品']   # 商城物品名称
b = [20, 30, 50, 10, 2000, 300]  # 商品价格
c = list()  # 购物车
e = 1
flag = True  # 标志位
while e > 0:
    for i in range(len(a)):
        s = input("请你输入想要的商品:" + "\n")
        if s in a:
            if b[i] <= money:
                print(str(a[i]) + "单价为" + str(b[i]))
                c.append(a[i])
                money -= b[i]
                print("恭喜，购买成功！您的卡余额还剩:"+str(money))
                print("继续购物")
            else:
                print("穷鬼，钱不够！请到其他超市购买！")
                flag = False
                break
        else:
            print("没有这个商品，别瞎弄！")
            print("继续购物")

    if not flag:
        break  # 退出外层循环

    s1 = input("输入Q或者q,退出系统:" + "\n")
    if s1 == "Q" or s1 == "q":
        break

print("\n您的购物车商品如下:")
for k in range(len(c)):
    print(str(c[k]) + " 单价为 " + str(b[k]))
print("总共花费"+str(5000 - money))




